package com.googlecode.chigs.web.common;

import org.apache.wicket.ajax.AbstractDefaultAjaxBehavior;
import org.apache.wicket.ajax.AjaxRequestTarget;
import org.apache.wicket.markup.html.IHeaderResponse;

/**
 * 
 * @author Ingo Renner
 * @author Henning Teek
 *
 */
public class KeepAliveBehavior  extends AbstractDefaultAjaxBehavior {

	@Override
	protected void respond(AjaxRequestTarget target) {
		// prevent wicket changing focus
		target.focusComponent(null);
	}
	
	@Override
	public void renderHead(IHeaderResponse response) {
		super.renderHead(response);
		response.renderOnLoadJavascript(
				"setInterval(function() { " +
				"  wicketAjaxGet('" + getCallbackUrl(true) + "', null, null, null); " +	"}, 600000);");
	}
}
